﻿namespace LeetCodeProject._0001_1000._001_100._21_30._027;

public class Solution
{
    public int RemoveElement(int[] nums, int val)
    {
        if (nums == null || nums.Length == 0)
            return 0;
        var i = 0;
        var j = nums.Length - 1;
        while (i <= j)
        {
            if (nums[i] == val)
                nums[i] = nums[j--];
            else
                i++;
        }

        return i;
    }
}